Addition of Enumeration Values

Hi,

One step forward and two steps back. Having populated a list dbe with the current enumerations of a specific datatype, I want to add a user specified value to the enumeration list via a field dbe. The code below has been cobbled together from various forum postings and the DXL reference manual. It runs without error but fails to add a new enumeration value. Am I almost there?

Thanks

Mark
 

void addPlfm(DBE dbe)
{
    AttrType at = find(current ,"platform")
        AttrSize = at.size
     for (i=0;i<AttrSize;i++)
        {
          print at.values[i] ": " at.strings[i] "\n" //current values are output correctly
        }
        string p = get(newPlfm) // New enumeration from DBE Field
        string errMess = ""
        string new_strings[at.size+1]
        int new_values[at.size+1] 
        int new_colors[at.size+1] 
        for(i=0;i < at.size; i++) 
        { 
                new_strings[i] = at.strings[i] 
                new_values[i] = at.values[i] 
                new_colors[i] = at.colors[i]  
        } 
        
        new_strings[at.size] = p
        new_values[at.size] = at.size 
        new_colors[at.size] = -1
        
        AttrType at_new = modify(at,"platform",new_strings,new_values,new_colors,errmsg)
}

mwilliamson - Tue Sep 15 11:33:31 EDT 2009

Re: Addition of Enumeration Values
llandale - Tue Sep 15 12:30:13 EDT 2009

Here's from the v9.2 manual:

AttrType modify(AttrType type, string newName [, string codes[ ], int values[ ], int colors[ ], 
       string descs[ ],[int arrMaps[ ],]] string &errmess)
 
If supplied, codes, values, colors and descs modify those properties of an existing enumerated type. 
In the GUI, the term values maps to codes, and the term related numbers maps to values. 
If the type is being used by an attribute, colors cannot be added where they weren't previously assigned, 
and, arrMaps must be supplied in order to map old values to the new ones.

 


You are missing copying over the 'descriptions' of each of the enumerations (which is new, and I see not available in the GUI). You are also missing the mapping array, which tells DOORS which of the new enumerations are mapped to which of the old one (perhaps if you are moving an enum, or perhaps inserting into the middle).

Before your loop you need: string new_descshttp://at.size+1; int new_maphttp://at.size+1
In your loop you need: new_descs[i] = at.descs[i]; new_map[i] = i.
After your loop you need: new_descshttp://at.size = ""; new_maphttp://at.size = -1
You need to add those two new arrays before 'errmsg' in the 'modify' command.
You really should replace most of those 'at.size' with 'AttrSize'.

 

 

 

  • Louie

 

 

Re: Addition of Enumeration Values
mwilliamson - Tue Sep 15 15:17:18 EDT 2009

llandale - Tue Sep 15 12:30:13 EDT 2009

Here's from the v9.2 manual:

AttrType modify(AttrType type, string newName [, string codes[ ], int values[ ], int colors[ ], 
       string descs[ ],[int arrMaps[ ],]] string &errmess)
 
If supplied, codes, values, colors and descs modify those properties of an existing enumerated type. 
In the GUI, the term values maps to codes, and the term related numbers maps to values. 
If the type is being used by an attribute, colors cannot be added where they weren't previously assigned, 
and, arrMaps must be supplied in order to map old values to the new ones.

 


You are missing copying over the 'descriptions' of each of the enumerations (which is new, and I see not available in the GUI). You are also missing the mapping array, which tells DOORS which of the new enumerations are mapped to which of the old one (perhaps if you are moving an enum, or perhaps inserting into the middle).

Before your loop you need: string new_descshttp://at.size+1; int new_maphttp://at.size+1
In your loop you need: new_descs[i] = at.descs[i]; new_map[i] = i.
After your loop you need: new_descshttp://at.size = ""; new_maphttp://at.size = -1
You need to add those two new arrays before 'errmsg' in the 'modify' command.
You really should replace most of those 'at.size' with 'AttrSize'.

 

 

 

  • Louie

 

 

Many thanks Louie,

I made the alterations and with the exception of at.descs, which does not seem to be recognised in my DOORS 9.2 client, it is working ok.

Lots of error checking and access checking to do but the core function is there.

Thanks again

Mark

Re: Addition of Enumeration Values
llandale - Tue Sep 15 17:50:20 EDT 2009

mwilliamson - Tue Sep 15 15:17:18 EDT 2009
Many thanks Louie,

I made the alterations and with the exception of at.descs, which does not seem to be recognised in my DOORS 9.2 client, it is working ok.

Lots of error checking and access checking to do but the core function is there.

Thanks again

Mark

Dang, gotta preview, sorry.

Looks like its 'at.descriptions[i]'

I see the AT can have a 'description' starting in v9.0, but I see no where in the GUI manual how you place or view a 'description' on each enumerated value. but I see that it can be good, use a short Accronym as the string and spell it out in the Description.

  • Louie

Re: Addition of Enumeration Values
KBSri - Wed Jun 04 05:33:46 EDT 2014

llandale - Tue Sep 15 17:50:20 EDT 2009
Dang, gotta preview, sorry.

Looks like its 'at.descriptions[i]'

I see the AT can have a 'description' starting in v9.0, but I see no where in the GUI manual how you place or view a 'description' on each enumerated value. but I see that it can be good, use a short Accronym as the string and spell it out in the Description.

  • Louie

Hello,

Can you please let me know how to add an enum value to the attribute??